package ru.papergames.battleserver.network.serverpackets.webserver;

import org.apache.log4j.Logger;
import ru.papergames.battleserver.model.battle.AbstractBattle;

/**
 * @author: ATroshanin
 * Date: 11.06.2010
 * Time: 17:31:44
 */
public class BattleFinishNotification extends WebServerServerPacket {

    private static final Logger log = Logger.getLogger(BattleFinishNotification.class.getName());

    private AbstractBattle battle;

    public BattleFinishNotification(AbstractBattle battle) {
        this.battle = battle;
    }

    @Override
    protected void writePacketId() {
        writeC(BATTLE_FINISH_NOTIFICATION_PACKET_ID);
    }

    @Override
    protected void writePacketData() {
        log.info("BattleFinishNotification.writePacketData[" + battle.getBattleOrderId() + "]");
        writeD(battle.getBattleOrderId());
        writeBool(battle.isWinnerFound());
        writeC(battle.getWinnerTeamId());
        // TODO: send players info
    }

    @Override
    public String getType() {
        return "[s] BattleFinishNotification[" + BATTLE_FINISH_NOTIFICATION_PACKET_ID + "]";
    }

}
